package com.cyys.modules.system.model.notification;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cyys.common.utils.StringUtil;
import com.cyys.common.validate.Edit;
import com.cyys.common.validate.Insert;
import com.cyys.modules.core.model.CoreBean;
import com.cyys.modules.core.sysParam.ParamBasicUtil;
import com.cyys.modules.core.sysParam.ParamConstants;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.util.Date;

@Data
@TableName("sys_version")
public class Version extends CoreBean {

	@NotBlank(message = "版本号不能为空",groups = {Edit.class, Insert.class})
	private String version;  //版本号
	
	private Date dateUpdate; //版本更新时间

	@Length(max = 1000,message = "版本更新内容不能大于1000个字符",groups = {Edit.class, Insert.class})
	@NotBlank(message = "版本更新内容不能为空",groups = {Edit.class, Insert.class})
	private String content;  //版本更新内容

	@NotBlank(message = "版本类型不能为空",groups = {Edit.class, Insert.class})
	private String type;  //版本类型

	@TableField(updateStrategy= FieldStrategy.NOT_NULL)
	private String attachments;  //附件

	@TableField(fill = FieldFill.INSERT)
	private Date dateCreate;

	@JsonIgnore
	public String getTypeName() {
		if(StringUtil.isNotEmpty(type))
			return ParamBasicUtil.getParamBasicTypeMap().get(ParamConstants.VERSION_TYPE).get(type);
		return null;
	}

}
